package com.tt.vtg.scenario.http.encoder;

import com.tt.vtg.scenario.util.json.JsonUtils;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.nio.charset.Charset;

/*
* It is a outbound handler.
* */
public abstract class AbstractHttpJsonEncoder<T> extends MessageToMessageEncoder<T>{
    protected final static Charset UTF_8 = Charset.forName("utf-8");

    protected ByteBuf _encode(Object o){
        return Unpooled.copiedBuffer(JsonUtils.toJson(o), UTF_8);
    }
}
